package cn.wolfcode.luowowo.packagetour.template;

import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Document(indexName="luowowo_packagetourcomment",type="packagetourcomment")
@Getter
@Setter
public class PackageTourCommentTemplate implements Serializable {
    public static final String INDEX_NAME = "luowowo_packagetourcomment";
    public static final String TYPE_NAME = "packagetourcomment";
    @Id
    //@Field 每个文档的字段配置（类型、是否分词、是否存储、分词器 ）
    @Field(store=true, index = false,type = FieldType.Long)
    private Long id;
    @Field(store=true, index = true,type = FieldType.Long)
    private Long packageTourId;         //跟团游信息id

    @Field(store=true, index = true,type = FieldType.Integer)
    private Integer schedulScore;       //行程安排评分
    @Field(store=true, index = true,type = FieldType.Integer)
    private Integer accommodationScore; //食宿评分
    @Field(store=true, index = true,type = FieldType.Integer)
    private Integer guideScore;         //司导评分
    @Field(store=true, index = true,type = FieldType.Integer)
    private Integer serviceScore;       //客服评分
    @Field(store=true, index = true,type = FieldType.Integer)
    private Integer avgScore;           //平均分评分
    @Field(index=true,analyzer="ik_max_word",store=true,searchAnalyzer="ik_max_word",type = FieldType.Text)
    private String commentTags;         //评论标签
    @Field(store=true, index = true,type = FieldType.Integer)
    private Integer commendNum;         //推荐数
    @Field(store=true, index = true,type = FieldType.Integer)
    private Integer commonNum;          //一般数
    @Field(store=true, index = true,type = FieldType.Integer)
    private Integer unCommendNum;       //不推荐数
    @Field(store=true, index = true,type = FieldType.Integer)
    private Integer hasImageNum;        //有图数
    @Field(store=true, index = true,type = FieldType.Long)
    private Long userId;                //用户id
    @Field(index=true,analyzer="ik_max_word",store=true,searchAnalyzer="ik_max_word",type = FieldType.Text)
    private String userName;            //用户名
    @Field(index=true,analyzer="ik_max_word",store=true,searchAnalyzer="ik_max_word",type = FieldType.Text)
    private String headImgUrl;          //用户头像
    @Field(index=true,analyzer="ik_max_word",store=true,searchAnalyzer="ik_max_word",type = FieldType.Text)
    private String commentContent;      //评论内容
    @Field(index=true,analyzer="ik_max_word",store=true,searchAnalyzer="ik_max_word",type = FieldType.Text)
    private String commentImages;       //评论照片
    @Field(pattern = "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis", type=FieldType.Date, format = DateFormat.custom)
    private Date commentTime;           //评论时间
    @Field(index=true,analyzer="ik_max_word",store=true,searchAnalyzer="ik_max_word",type = FieldType.Text)
    private String shopReply;           //商家回复

    public List<String> getImgs(){
        ArrayList<String> list = new ArrayList<>();
        if (commentImages != null && commentImages.length()>0){
            String[] strs = commentImages.split(",");
            for (String s : strs) {
                list.add(s);
            }
        }
        return list;
    }
    public List<String> getTags(){
        ArrayList<String> list = new ArrayList<>();
        if (commentTags != null && commentTags.length()>0){
            String[] strs = commentTags.split(",");
            for (String s : strs) {
                list.add(s);
            }
        }
        return list;
    }

}
